from datetime import datetime,timedelta
from selenium import webdriver
from login import login
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support.select import Select

import crawlers
import web_operation
import word_operation 

chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option('useAutomationExtension',False)
chrome_options.add_experimental_option("excludeSwitches",['enable-automation'])
chrome_options.add_experimental_option("detach",True)

class Constant:
    error = ""
    #now_date = datetime.now().strftime("%Y-%m-%d")
    #last_date = (datetime.now() - timedelta(days=6)).strftime("%Y-%m-%d")
    now_date = '2025-03-14'
    last_date = '2025-03-13'
    save_path = r'E:\CodeSpace\news-crawlers'

Browser = webdriver.Chrome(options=chrome_options)
Browser.implicitly_wait(5)
#返回的Browser对应学习进行时页面
Browser,Constant.error = login.login_politics(Browser,Constant,chrome_options)
Browser,Constant.error = crawlers.main(Browser,Constant) ##将学习进行时12个页面全部遍历下载完成，返回的browser是“时政-新华网”



